<?php

class Template extends ObjLib\Object {
	var $params = array (
		'title',
		'content'
	);
		
	function Template ($id = false, $title = false) {
		$this->id = $id;
		$this->title = $title;
		
		if ($this->id !== false) {
			$this->load ();
		}
	}
 
	function createTable () {
		global $dbh;
  
  		$tableName = get_class ($this);
		
		$query = <<<QUERY
CREATE TABLE `{$tableName}` (
  `id` int(10) char(32) not null,
  `title` varchar(255) NOT NULL,
  `content` TEXT,
  PRIMARY KEY  (`id`),
  KEY `title_index` (`title`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
QUERY;
		$dbh->exec ($query);
		return true;
	}
	
	function fillNextPosition ($con) {
		$this->content = str_replace('<?php /*TMPL_POS*/ ?>', $con, $this->content);
	}
	
	function getContent() {
		return $this->content; 
	}
}

?>